package my.headfirstjava.observer.v1;

import java.util.ArrayList;
import java.util.List;

/**
 * author: xl
 * time: 2018/8/23 9:35
 * description:
 **/
public class Subject {


    List<Observer> list= new ArrayList<>();


    //预定
    public void add(Observer observer){
        list.add(observer);
    }

    //取消预定
    public void cancel(Observer observer){
        list.remove(observer);
    }


    public void notifyObjectAll(String msg){
        for (Observer observer:list){
            observer.update(msg);
        }
    }



}
